#include <cstdio>
#include <iostream>
#include <ostream>
#include <string>

using namespace std;

class Person {
  public:
    Person(string i, string n, string s, string a, string p);
    virtual ~Person() = default;
    void setID(string i);
    void setName(string n);
    void setSex(string s);
    void setAddress(string a);
    void setPhoneNumber(string p);
    virtual void displayInfo(void);

  protected:
    string ID;
    string name;
    string sex;
    string address;
    string phoneNumber;
};
Person::Person(string i, string n, string s, string a, string p) {
    ID = i;
    name = n;
    sex = s;
    address = a;
    phoneNumber = p;
}
void Person::setID(string i) { ID = i; }
void Person::setName(string n) { name = n; }
void Person::setSex(string s) { sex = s; }
void Person::setAddress(string a) { address = a; }
void Person::setPhoneNumber(string p) { phoneNumber = p; }
void Person::displayInfo(void) {
    cout << "编    号：" << ID << endl;
    cout << "姓    名：" << name << endl;
    cout << "性    别：" << sex << endl;
    cout << "家庭住址：" << address << endl;
    cout << "联系电话：" << phoneNumber << endl;
}

class Student : public Person {
  public:
    Student(int ma, int ph, int en, int cp, string i, string n, string s,
            string a, string p)
        : Person(i, n, s, a, p) {
        math = ma;
        physics = ph;
        english = en;
        cprogramming = cp;
    }
    void setScore(char tag, int score);
    virtual void displayInfo(void) override;

  protected:
    int math;
    int physics;
    int english;
    int cprogramming;
};

void Student::setScore(char tag, int score) {
    if (tag == 'm')
        math = score;
    else if (tag == 'p')
        physics = score;
    else if (tag == 'e')
        english = score;
    else if (tag == 'c')
        cprogramming = score;
}
void Student::displayInfo(void) {
    Person::displayInfo();
    cout << "数    学：" << math << endl;
    cout << "物    理：" << physics << endl;
    cout << "英    语：" << english << endl;
    cout << "程序设计：" << cprogramming << endl;
}

class Teacher : public Person {
  public:
    Teacher(string ti, double sa, string i, string n, string s, string a,
            string p)
        : Person(i, n, s, a, p) {
        title = ti;
        salary = sa;
    }
    void setTitle(string t);
    void setSalary(double s);
    virtual void displayInfo(void) override;

  protected:
    string title;
    double salary;
};

void Teacher::setTitle(string t) { title = t; }
void Teacher::setSalary(double s) { salary = s; }
void Teacher::displayInfo(void) {
    Person::displayInfo();
    cout << "职    称：" << title << endl;
    cout << "工    资：" << salary << endl;
}

int main() {
    Person *person;
    cout << "ID name sex address phoneNumber" << endl;
    string ID, name, sex, address, phoneNumber;
    cin >> ID >> name >> sex >> address >> phoneNumber;
    Person hip(ID, name, sex, address, phoneNumber);
    person = &hip;
    person->displayInfo();
    cout << "set phoneNumber" << endl;
    cin >> phoneNumber;
    person->setPhoneNumber(phoneNumber);
    person->displayInfo();
    cout << "ID name sex address phoneNumber math physics english cprogramming"
         << endl;
    int math, physics, english, cprogramming;
    cin >> ID >> name >> sex >> address >> phoneNumber >> math >> physics >>
        english >> cprogramming;
    Student Kiki(math, physics, english, cprogramming, ID, name, sex, address,
                 phoneNumber);
    person = &Kiki;
    person->displayInfo();
    cout << "set grade" << endl;
    char tag;
    int grade;
    cin >> tag >> grade;
    Kiki.setScore(tag, grade);
    person->displayInfo();
    cout << "ID name sex address phoneNumber title salary" << endl;
    string title;
    double salary;
    cin >> ID >> name >> sex >> address >> phoneNumber >> title >> salary;
    Teacher Chuchu(title, salary, ID, name, sex, address, phoneNumber);
    person = &Chuchu;
    person->displayInfo();
    cout << "set salary" << endl;
    cin >> salary;
    Chuchu.setSalary(salary);
    person->displayInfo();
    return 0;
}
